import actionTypes from "../action";
import { checkImage, checkName, checkPhone } from "./rules";
export default {
  [actionTypes.PERSONNEL_MANAGE]: {
    title: "员工信息",
    form: [
      {
        type: "image",
        prop: "avatarUrl",
        upKey: "avatarFileKey",
        label: "员工头像",
      },
      {
        type: "text",
        prop: "staffName",
        label: "员工姓名",
        placeholder: "请输入员工姓名",
        rule: [
          { required: true, validator: checkName, trigger: "change" },
          {
            max: 10,
            message: "员工姓名不能超过10个字",
            trigger: "change",
          },
        ],
      },
      {
        type: "number",
        prop: "mobile",
        label: "员工电话",
        placeholder: "请输入手机号码",
        rule: { required: true, validator: checkPhone, trigger: "change" },
      },
      {
        type: "password",
        prop: "password",
        label: "登陆密码",
        rule: { required: true, message: "请输入登陆密码", trigger: "blur" },
      },
      {
        type: "password",
        prop: "affirmPassword",
        label: "确认密码",
        show(data, type, $store) {
          if (type === "view") {
            return false;
          }
          if (type === "add") {
            return true;
          }
          return data.password !== $store.state.table.currentData.password;
        },
        equal: "password",
        equalText: "请输入相同的密码",
        placeholder: "请再次输入密码",
        rule: { required: true, message: "请确认登陆密码", trigger: "blur" },
      },
      {
        type: "select",
        label: "省份",
        prop: "provinceCode",
        cascader: "cityCode",
        placeholder: "请选择省份",
        option(_, $store) {
          return $store.getters["dic/province"];
        },
        auto_dispatch: "dic/getCityDic",
        rule: { required: true, message: "省份不能为空", trigger: "blur" },
      },
      {
        type: "select",
        label: "城市",
        prop: "cityCode",
        placeholder: "请选择城市",
        option(_, $store) {
          return $store.getters["dic/city"];
        },
        dispatch: "dic/getCity",
        rule: { required: true, message: "城市不能为空", trigger: "blur" },
      },
      {
        type: "image",
        label: "身份证正面",
        prop: "idFrontUrl",
        upKey: "idFrontFileKey",
        rule: { required: true, validator: checkImage, trigger: "change" },
      },
      {
        type: "image",
        label: "身份证正面",
        prop: "idContraryUrl",
        upKey: "idContraryFileKey",
        rule: [{ required: true, validator: checkImage, trigger: "change" }],
      },
    ],
  },
};
